<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">

        function test(){

        }
        console.log(test.prototype)
        //声明一个Person函数
        function Person() {
            //最好不要在这里 定义函数   这里会浪费内存 
        }
      
        Person.prototype.name = "张三";
        Person.prototype.age = 22;
        Person.sayName=function(){
            console.log("说名字"+this.name)
        }
       
        var p=new Person()
        console.log(p.__proto__==Person.prototype)
        console.log(Person.prototype)
        console.log(p)
        function Student(){

        }
        //继承Person
        Student.prototype=new Person() ;
        Student.prototype.name='study'
        var s=new Student()
        console.log(s)
        console.log(s.name)
        console.log('===============测试原型==================');
     
       var res=Person.prototype.isPrototypeOf(s)
       console.log(res)
      console.log('========================js原型模式==============================');
      const obj1={a:1,b:2};
      const obj2=Object.create(obj1)
      console.log("object_create判断1",obj1)
      console.log("object_create判断2",obj2)
    </script>
</body>

</html>